﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace PB.Airsoft.Web.Acount.controls
{
    public partial class LoginControl : System.Web.UI.UserControl
    {
        private DisplayMode ControlDisplayMode
        {
            get { return (DisplayMode)ViewState["DisplayMode"]; }
            set { ViewState["DisplayMode"] = value; }
        }

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
                this.ControlDisplayMode = DisplayMode.Login;
        }

        protected void Page_PreRender(object sender, EventArgs e)
        {
            switch (this.ControlDisplayMode)
            {
                case DisplayMode.Login:
                    loginPanel.Visible = true;
                    registrationPanel.Visible = false;
                    break;
                case DisplayMode.Registration:
                    loginPanel.Visible = false;
                    registrationPanel.Visible = true;
                    break;
                default:
                    throw new NotImplementedException();
            }
        }

        protected void btnCreateNew_Click(object sender, EventArgs e)
        {
            this.ControlDisplayMode = DisplayMode.Registration;
        }

        protected void btnLogin_Click(object sender, EventArgs e)
        {
            this.ControlDisplayMode = DisplayMode.Login;
        }

        private enum DisplayMode
        {
            Login,
            Registration
        }
    }
}